package com.oaoa.main.dao.base;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import com.oaoa.main.entity.TestEntity;
@Repository
public class TestDao implements TestDAOI {
	HibernateTemplate ht = null;
	private SessionFactory sessionFactory;
	
	

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public HibernateTemplate getHibernateTemplate() {
		if (ht == null)
			return new HibernateTemplate(sessionFactory);

		return ht;
	}

	public Integer save(TestEntity testEntity ){
		return (Integer) getHibernateTemplate().save(testEntity);
	}
	
	
	@SuppressWarnings("unchecked")
	public List<TestEntity> findAll() {
		return getHibernateTemplate().find("from TestEntity");

	}

}
